
// 求其中的不同的那个元素
var arr = [1, 2, 1, 2, 3, 3, 4, 5, 5, 6, 6]
var arr1 = ['a', 'a', 'b', 'c', 'c']

function foo (arr) {
    let obj = {}
    arr.forEach((val, i) => {
        obj[val] ? delete obj[val] : obj[val] = val
    })
    return Object.values(obj)[0];
}

function bar (arr) {
    arr.sort()
    let i = 0;
    let obj = {};
    while (true) {
        if (arr[i] !== arr[i-1] && arr[i] !== arr[i+1]) {
            obj.index = i
            obj.value = arr[i]
            break;
        } 
        i++;
    }
    return obj;
}

function baz (arr) {
    let i = 0;
    let obj = {};
    while (true) {
        if (arr.indexOf(arr[i]) === arr.lastIndexOf(arr[i])) {
            obj.index = i
            obj.value = arr[i]
            break;
        } 
        i++;
    }
    return obj;
}

function qux (arr) {
    return arr.reduce((a, b) => a ^ b)
}

console.log(foo(arr))
console.log(bar(arr))
console.log(baz(arr))
console.log(baz(arr1))
console.log(qux(arr))
